package net.hxz.modules.controller.backEnd;

import net.hxz.modules.controller.BaseController;
import net.hxz.modules.pojo.News;
import net.hxz.modules.services.INewsService;
import net.wy.myBatisPlugin.page.model.PageRowBounds;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
@RequestMapping("backEnd/news/")
public class BackEndNewsController extends BaseController{
	private final String PATH = "backEnd/modules/news/";
	
	@Autowired
	private INewsService newsService;
	
    @RequestMapping("list")
    public String list(PageRowBounds page, ModelMap map) {
        map.put("list", newsService.list(page));
        map.put("page", page);
        return PATH + "list";
    }
    
    @RequestMapping("add")
    public String newRoot() {
        return PATH + "add";
    }
    
    
    @RequestMapping("mod")
    public String mod(Long newsId, ModelMap map) {
    	map.put("news", newsService.get(newsId));
        return PATH + "mod";
    }
    
	@RequestMapping(value = "/add.json")
	public void add(News news, ModelMap map) {
		newsService.add(news);
	}
	
	@RequestMapping(value = "/mod.json")
	public void mod(News news, ModelMap map) {
		newsService.mod(news);
	}
	
	@RequestMapping(value = "/del.json")
	public void del(Long newsId, ModelMap map) {
		newsService.del(newsId);
	}
}

